<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var a = {
        username:'frank',
        friends:['tom','jack']

    }
var b = {
        c:333
};

//    b['username'] = a['username']
//    b['friends'] = a['friends']

    //对象的浅拷贝
    function copyOject (from,to){
        var to = typeof to === 'object' ? to:{};
        for(var i in from){
            to[i] = from[i]
        }
        return to;
    }

    var b = copyOject(a,b);

    console.log(a);
    console.log(b);
    a.friends === b.friends     //true
</script>
</body>
</html>